package aisLogic;

import java.util.LinkedList;
import java.util.Observable;

public class Animation extends Observable
{
	private int id = 0;
	private LinkedList<FrameRef> frameRef = new LinkedList<FrameRef>();
	
	public Animation(int id)
	{
		super();
		this.id = id;
	}

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
		this.setChanged();
		this.notifyObservers();
	}

	
	public int getSize()
	{
		return this.frameRef.size();
	}
	
	public void addFrameRef(FrameRef m)
	{
		this.frameRef.add(m);
		this.setChanged();
		this.notifyObservers();
	}
	
	public void removeFrameRef(int index)
	{
		this.frameRef.remove(index);
		this.setChanged();
		this.notifyObservers();
	}
	
	public FrameRef getFrameRef(int index)
	{
		return (FrameRef)this.frameRef.get(index);
	}
	
	public FrameRef[] getFrameRef(int from, int to)
	{
		FrameRef[] f = new FrameRef[to-from];
		for(int i = from; i<to; i++)
		{
			f[to -i] = this.getFrameRef(to -i);
		}
		return f;
	}
	
	public FrameRef[] getAllFrameRef()
	{
		return this.getFrameRef(0, this.getSize());
	}

}
